<template>
    <div>
        <div class="title">近日新增课程数</div>
        <el-row>
            <el-table :data="data" height="375" border style="width: 100%" :header-cell-style="{textAlign: 'center'}" :cell-style="{ textAlign: 'center' }">
                <el-table-column label="日期" prop="createTime" align="center">
                    <template #default="scope">
                        <el-icon><timer /></el-icon>{{scope.row.createTime}}
                    </template>
                </el-table-column>
                <el-table-column label="新增数量" prop="count" align="center"></el-table-column>
            </el-table>
        </el-row>
    </div>
</template>

<script>
import { newCourses } from '#/Home/Home'
import { reactive,toRefs } from 'vue-demi';
export default {
    setup() {
        const state = reactive({
            data: []
        });
        const init = async () => {
            await newCourses().then(res => {
                if(res.data.ret === 0) {
                    state.data = res.data.data.data.reverse();
                }
            })
        }
        init()
        return {
            ...toRefs(state),
            init
        }
    }
}
</script>

<style lang="less" scoped>
.title {
  font-weight: bold;
  margin-bottom: 20px;
}
</style>